package com.cardone.platform.authority.service;

import java.util.List;

import lombok.Getter;
import lombok.Setter;

import org.springframework.transaction.annotation.Transactional;

import com.cardone.common.dto.PaginationDto;
import com.cardone.context.ContextHolder;
import com.cardone.platform.authority.dao.PermissionOrgDao;
import com.cardone.platform.authority.dto.PermissionOrgDto;

/**
 * 许可与组织服务
 *
 * @author yaohaitao
 *
 */
@Getter
@Setter
@Transactional(readOnly = true)
public class PermissionOrgDefaultService implements PermissionOrgService {
	@Override
	@Transactional
	public int deleteByIds(final PermissionOrgDto deletePermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).deleteByIds(deletePermissionOrg);
	}

	@Override
	public <P> P findByCodeOrId(final Class<P> mappedClass, final PermissionOrgDto findPermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).findByCodeOrId(mappedClass, findPermissionOrg);
	}

	@Override
	public <P> P findById(final Class<P> mappedClass, final PermissionOrgDto findPermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).findById(mappedClass, findPermissionOrg);
	}

	@Override
	public <P> List<P> findList(final Class<P> mappedClass) {
		return ContextHolder.getBean(PermissionOrgDao.class).findList(mappedClass);
	}

	@Override
	public <P> List<P> findListByLikeCode(final Class<P> mappedClass, final PermissionOrgDto findListPermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).findListByLikeCode(mappedClass, findListPermissionOrg);
	}

	@Override
	@Transactional
	public int insertByCode(final PermissionOrgDto insertPermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).insertByCode(insertPermissionOrg);
	}

	@Override
	public <P> PaginationDto<P> paginationByLikeCode(final Class<P> mappedClass, final PermissionOrgDto paginationPermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).paginationByLikeCode(mappedClass, paginationPermissionOrg);
	}

	@Override
	public Integer readByCodeNqIdForCount(final PermissionOrgDto readPermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).readByCodeNqIdForCount(readPermissionOrg);
	}

	@Override
	@Transactional
	public <P> P saveByIdOrCode(final Class<P> mappedClass, final PermissionOrgDto savePermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).saveByIdOrCode(mappedClass, savePermissionOrg);
	}

	@Override
	@Transactional
	public PermissionOrgDto saveByIdOrCode(final PermissionOrgDto savePermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).saveByIdOrCode(PermissionOrgDto.class, savePermissionOrg);
	}

	@Override
	@Transactional
	public int updateByCode(final PermissionOrgDto updatePermissionOrg) {
		return ContextHolder.getBean(PermissionOrgDao.class).updateByCode(updatePermissionOrg);
	}
}